package com.zhl.interface_Demo8;

import java.util.ArrayList;

public class StudentOperatorIpml1 implements StudentOperator {


    @Override
    public void printAllStudents(ArrayList<Student> students) {
        System.out.println("====全班学生信息====");
        for(int i=0;i<students.size();i++){
            Student s = students.get(i);
            System.out.println("姓名："+s.getName()+"  分数："+s.getScore()+"  性别："+s.getSex());
            }
    }

    @Override
    public void printAvergeScore(ArrayList<Student> students) {
        System.out.println("====全班学生平均分数====");
        double allscore = 0;
        int count = 0;
        for(int i=0;i<students.size();i++){
            Student s = students.get(i);
            allscore += s.getScore();
            count++;
        }
        double averge = allscore/count;
        System.out.println("平均分数："+averge);
    }
}
